package com.qiuqiu.controller;

import com.qiuqiu.entity.TodoList;
import com.qiuqiu.service.TodoListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：张艳杰
 * @description：TODO
 * @date ：Created in 2021/8/22 10:41
 * @modified By：
 * @version: 1.0
 */
@RestController
@CrossOrigin("*")
public class TodoListController {

    @Autowired
    private TodoListService todoListService;

    @RequestMapping("/getTodoList")
    private List<TodoList> getTodoList(){
        return this.todoListService.getTodoList();
    }

    @RequestMapping("/addList")
    private TodoList addList(String name){
        return this.todoListService.addList(name);
    }

    @RequestMapping("/delTodoList")
    private void delTodoList(Integer id){
       this.todoListService.delTodoList(id);
    }

    @RequestMapping("/isCompleted")
    private TodoList isCompleted(Integer id, Integer status ){
       return this.todoListService.isCompleted(id, status);
    }

    @RequestMapping("/clearCompleted")
    private String clearCompleted(){
        this.todoListService.clearCompleted();
        return "success";
    }

    @RequestMapping("/isEditing")
    private TodoList isEditing(Integer id, Integer status){
        return this.todoListService.isEditing(id, status);
    }

    @RequestMapping("/updateTaskName")
    private TodoList updateTaskName(Integer id, String taskName){
        return this.todoListService.updateTaskName(id, taskName);
    }

}
